   function ReadWeatherData() {
       readData("file etc/tests/weather.csv")
   }
   function readData(opt0,def,m,f,x,h, opt) {
      s2a("file /dev/stdin missing ? char # sep , all _all",def," ")
      s2a(opt0,opt," ")
      readData1(opt,def,m,f,x,h,
                thisOrThat("sep",    opt,def),
                thisOrThat("file",   opt,def),
                thisOrThat("char",   opt,def) ".*",
                thisOrThat("missing",opt,def),
                thisOrThat("all",    opt,def))
      oo(m,"m")
  }
 function thisOrThat(key,this,that) { 
     return key in this ? this[key] : that[key]
 }
 function readData1(opt,def,m,f,x,h,sep,file,comment,missing,all,       \
                    line,tmp,nf,nr,goals,expect) { 
     while ( (getline line < file) > 0) {
         sub(comment,"",line)
         if ( line ~ /^[ \t]*$/ ) 
             continue
         nf = split(line,tmp,sep)
         if ( nf < 2 ) 
             continue 
         if ( ++nr == 1 ) 
             expect = readFirstLine(tmp,m,goals)
         else { 
             if (nf != expect)
                 barph("bad line " line)
             else {
                 readLine(tmp,missing,nr,goals,m,f,x,h,readGoals(goals,m,tmp))
                 readLine(tmp,missing,0,goals,m,f,x,h,all)
             }
         }
     }
     close(com)
     notOk(nr == 0,"no data found")
  }
 function readFirstLine(tmp,m,goals,     n,goalp,i,cell) {
      for(i in tmp) {
          n++
          cell = tmp[i]
          goalp = m["goal",i] = (cell ~ /[!<>]/)
          if (goalp)
              goals[i] = i;
          if (cell ~ /\$/) {
              m["nump", i] = cell ~ /\$/
              m["want", i] = cell ~ />/
              m["hate", i] = cell ~ /</
          }
          gsub(/[^abcdefghijklmnopqrstuvwxyz_0123456789]/,"",cell)
          m["name",i] = cell
      }
      return n
  }
  function readGoals(goals,m,tmp,   i,out,sep) {
      for(i in goals) {
          out = out sep tmp[i]
          sep = "," 
      }
      return out
  }
  function readLine(tmp,missing,nr,goals,m,f,x,h,c,  i,cell) {
      h[c]++
      for(i in tmp) { 
          cell = tmp[i]
          if(tmp[i] ~ missing) 
              continue;
          if (("nump",i) in m) {
              if (! ((c,"min",i) in m))  {
                  m[c,"min",  i] = 10^32
                  m[c,"max",  i] = -1*10^32  
                  m[c,"sum",  i] = 0
                  m[c,"sumSq",i] = 0
                  m[c,"n",    i] = 0
              }
              m[c,"n",    i] += 1
              m[c,"sum",  i] += cell
              m[c,"sumSq",i] += cell * cell
              if (cell > m[c,"max",i])  
                  m[c,"max",i] = cell;
              if (cell < m[c,"min",i])  
                  m[c,"min",i] = cell;
          } else {
              f[c,i,cell]++
              if (nr)
                  x[i,cell,++x[i,cell,0]] = nr 
          }}
  }

